#include"DecisionMaking.hpp"
#include<unordered_map>
using namespace RobotDec;

void test1()
{
    unordered_map<size_t, Identity> v;
   Identity i1;
   Rember r1;
   bitset<64> b1;
   b1.set(1);

   r1._name = 6;
   r1._action = ACTION_BUMPFISR;
   r1._emotion = EMO_ANGRY;
   r1._attitude = ATT_NORMAL;
   r1._model = MOD_NORMAL;
   r1._probability = 0.6;

   i1._name = r1._name;
   // i1._history = r1;
   i1._mode = r1._model;
   i1._actions = b1;

   v.insert({i1._name, i1});
   v.insert({ 20, Identity() });

   StoreIdentity::WriteIdentityToFile(v, DATA_PATH);

   unordered_map<size_t, Identity> v2;
   StoreIdentity::ReadIdentitiesFromFile(&v2, DATA_PATH);
   for (auto& i : v2)
   {
       cout << i.first << ":" << i.second._name << endl;
   }
   int h = 10;
   while(true)
   {

   }
}
void test2()
{
    unordered_map<size_t, Identity> v;
       Identity i1;
       Rember r1;
       bitset<64> b1;
       b1.set(11);
       b1.set(1+BIT_OFFSET);
       r1._name = 6;
       r1._action = ACTION_BUMPFISR;
       r1._emotion = EMO_LOVE;
       r1._attitude = ATT_NORMAL;
       r1._model = MOD_FRIENDLY;
       r1._probability = 1;
       i1._name = r1._name;
       // i1._history = r1;
       i1._mode = 10;
       i1._actions = b1;
       i1._mrem->Push(r1);
       v.insert({i1._name, i1});
       StoreIdentity::WriteIdentityToFile(v, DATA_PATH);

     /*  unordered_map<size_t, Identity> v2;
       StoreIdentity::ReadIdentitiesFromFile(&v2, DATA_PATH);
       for (auto& i : v2)
       {
           cout << i.first << ":" << i.second._name << endl;
       }*/
    RobotDec::Desion my_desion;
    int i = 1;
    cout << "1------------------" << endl << endl;

    //第一个人的记忆交互
    while (i <= 200)
    {
        Response result;
        RobotDec::Input inp;
        inp._name = 1;
        inp._voice = 11;
        inp._pose = 1;
        /* cin >> inp._name >> inp._voice >> inp._pose;
         cin.ignore(256, '\n');*/
        bool res = my_desion.Start(inp, &result);
        if (!res)
        {
            result._expression += " 忽略，没有决策!";
        }
        else {
            result._expression += " 决策成功!";
        }
        std::string str = result.Serialize();
        cout << "第 " << i++ << " 次：" << str << endl;
        sleep(1);
    }
}
void test3()
{
    RobotDec::Desion my_desion;
    int i = 1;
    cout << "1------------------" << endl << endl;

    //第一个人的记忆交互
    while (i <= 200)
    {
        Response result;
        RobotDec::Input inp;
        inp._name = 1;
        inp._voice = 11;
        inp._pose = 1;
        /* cin >> inp._name >> inp._voice >> inp._pose;
         cin.ignore(256, '\n');*/
        bool res = my_desion.Start(inp, &result);
        if (!res)
        {
            result._expression += " 忽略，没有决策!";
        }
        else {
            result._expression += " 决策成功!";
        }
        std::string str = result.Serialize();
        cout << "第 " << i++ << " 次：" << str << endl;
        //Sleep(1000);
    }
    //2
    cout << "2------------------" << endl << endl;

    i = 1;
    while (i <= 200)
    {
        Response result;
        RobotDec::Input inp;
        inp._name = 2;
        inp._voice = 7;
        inp._pose = 0;
        /* cin >> inp._name >> inp._voice >> inp._pose;
         cin.ignore(256, '\n');*/
        bool res = my_desion.Start(inp, &result);
        if (!res)
        {
            result._expression += " 忽略，没有决策!";
        }
        else {
            result._expression += " 决策成功!";
        }
        std::string str = result.Serialize();
        cout << "第 " << i++ << " 次：" << str << endl;
        //Sleep(1000);
    }
    //3
    i = 1;
    cout << "3------------------" << endl << endl;
    while (i <= 200)
    {
        Response result;
        RobotDec::Input inp;
        inp._name = 3;
        inp._voice = 0;
        inp._pose = 10;
        /* cin >> inp._name >> inp._voice >> inp._pose;
         cin.ignore(256, '\n');*/
        bool res = my_desion.Start(inp, &result);
        if (!res)
        {
            result._expression += " 忽略，没有决策!";
        }
        else {
            result._expression += " 决策成功!";
        }
        std::string str = result.Serialize();
        cout << "第 " << i++ << " 次：" << str << endl;
        //Sleep(1000);
    }
    //4
    cout << "4------------------" << endl << endl;

    i = 1;
    while (i <= 200)
    {
        Response result;
        RobotDec::Input inp;
        inp._name = 4;
        inp._voice = 0;
        inp._pose = 12;
        /* cin >> inp._name >> inp._voice >> inp._pose;
         cin.ignore(256, '\n');*/
        bool res = my_desion.Start(inp, &result);
        if (!res)
        {
            result._expression += " 忽略，没有决策!";
        }
        else {
            result._expression += " 决策成功!";
        }
        std::string str = result.Serialize();
        cout << "第 " << i++ << " 次：" << str << endl;
        //Sleep(1000);
    }
    //5
    i = 1;
    cout << "5------------------" << endl << endl;

    while (i <= 200)
    {
        Response result;
        RobotDec::Input inp;
        inp._name = 5;
        inp._voice = 0;
        inp._pose = 12;
        /* cin >> inp._name >> inp._voice >> inp._pose;
         cin.ignore(256, '\n');*/
        bool res = my_desion.Start(inp, &result);
        if (!res)
        {
            result._expression += " 忽略，没有决策!";
        }
        else {
            result._expression += " 决策成功!";
        }
        std::string str = result.Serialize();
        cout << "第 " << i++ << " 次：" << str << endl;
        //Sleep(1000);
    }
    //6
    i = 1;
    while (i <= 100)
    {
        Response result;
        RobotDec::Input inp;
        inp._name = 6;
        inp._voice = 11;
        inp._pose = 0;
        /* cin >> inp._name >> inp._voice >> inp._pose;
         cin.ignore(256, '\n');*/
        bool res = my_desion.Start(inp, &result);
        if (!res)
        {
            result._expression += " 忽略，没有决策!";
        }
        else {
            result._expression += " 决策成功!";
        }
        std::string str = result.Serialize();
        cout << "第 " << i++ << " 次：" << str << endl;
        //Sleep(1000);
    }
}
void test4()
{
    RobotDec::Desion my_desion;
    cout << "------------------" << endl << endl;
    int j = 0;
    while (j < 10)
    {
        int i = 1;
        //第一个人的记忆交互
        cout << "-------" << j << "--------" << endl;
        cout << "--------------------------" << endl;
        if (j < 3)
        {
            while (i <= 200)
            {
                Response result;
                RobotDec::Input inp;
                inp._name = j+1;
                inp._voice = 11;
                inp._pose = 1;
                /* cin >> inp._name >> inp._voice >> inp._pose;
                 cin.ignore(256, '\n');*/
                bool res = my_desion.Start(inp, &result);
                if (!res)
                {
                    result._expression += " 忽略，没有决策!";
                }
                else {
                    result._expression += " 决策成功!";
                }
                std::string str = result.Serialize();
                cout << "第 " << i++ << " 次：" << str << endl;
                //Sleep(1000);
            }
        }
        else
        {
            while (i <= 200)
            {
                Response result;
                RobotDec::Input inp;
                inp._name = j+1;
                inp._voice = 0;
                inp._pose = 12;
                /* cin >> inp._name >> inp._voice >> inp._pose;
                 cin.ignore(256, '\n');*/
                bool res = my_desion.Start(inp, &result);
                if (!res)
                {
                    result._expression += " 忽略，没有决策!";
                }
                else {
                    result._expression += " 决策成功!";
                }
                std::string str = result.Serialize();
                cout << "第 " << i++ << " 次：" << str << endl;
                //Sleep(1000);
            }
        }
        j++;
    }
    int i = 1;
    while (i <= 100)
    {
        Response result;
        RobotDec::Input inp;
        inp._name = 0;
        inp._voice = 11;
        inp._pose = 0;
        /* cin >> inp._name >> inp._voice >> inp._pose;
         cin.ignore(256, '\n');*/
        bool res = my_desion.Start(inp, &result);
        if (!res)
        {
            result._expression += " 忽略，没有决策!";
        }
        else {
            result._expression += " 决策成功!";
        }
        std::string str = result.Serialize();
        cout << "第 " << i++ << " 次：" << str << endl;
        sleep(1);
    }

}
void test5()
{
    RobotDec::Desion my_desion;
    int i =0;
    while (i <= 10)
    {
        Response result;
        RobotDec::Input inp;
        inp._name = 0;
        inp._voice = 11;
        inp._pose = 0;
        bool res = my_desion.Start(inp, &result);
        if (!res)
        {
            result._expression += " 忽略，没有决策!";
        }
        else 
        {
            result._expression += " 决策成功!";
        }
        std::string str = result.Serialize();
        cout << "第 " << i++ << " 次：" << str << endl;
        sleep(1);
    }
}
int main()
{

    test5();
    // time_t t = time(NULL);
    // cout << t << endl;
    // time_t s;
    // sleep(2);
    // time(&s);
    // cout << s << endl;
    return 0;
}